from manim import *
from numpy import flip, insert

LV,QL,QH,JH='#75cfb8','#bbdfc8','#f0e5d8','#ffc478'

class p1(MovingCameraScene):
    def construct(self):
        # self.add(NumberPlane())
        # self.camera.frame.scale(0.5)
        # x^2+y^2=r^2 6,8,10
        circle =Circle(3).shift(LEFT)
        a=circle.get_right()+RIGHT*2
        b,c=[3*np.cos(53*DEGREES),3*np.sin(53*DEGREES),0]+LEFT,[3*np.cos(53*DEGREES),-3*np.sin(53*DEGREES),0]+LEFT
        o=ORIGIN+LEFT
        ba,bo,ca,co=Line(b,a),Line(b,o),Line(c,a),Line(c,o)
        self.add(circle,Dot(o),ba,bo,ca,co,Line(o,a),
            MathTex('A').next_to(a),
            MathTex('B').next_to(b,UR),
            MathTex('C').next_to(c,DR),
            MathTex('O').next_to(o,LEFT),
            Angle(ba,bo,elbow=True),
            Angle(ca,co,elbow=True)
        )
        self.wait()

class p2(MovingCameraScene):
    def construct(self):
        # self.add(NumberPlane())
        # self.camera.frame.scale(0.5)
        # x^2+y^2=r^2 6,8,10
        circle =Circle(1.5).shift(LEFT+DOWN*0.5)
        ab = TangentLine(circle, alpha=0.5, length=11)
        ac=TangentLine(circle, alpha=0.18, length=11)
        bc=TangentLine(circle, alpha=0.8, length=11)
        de=TangentLine(circle, alpha=0.02, length=11)
        a,b,c,d,e=line_intersection(ab.get_start_and_end(),ac.get_start_and_end()),line_intersection(ab.get_start_and_end(),bc.get_start_and_end()),line_intersection(bc.get_start_and_end(),ac.get_start_and_end()),line_intersection(ac.get_start_and_end(),de.get_start_and_end()),line_intersection(bc.get_start_and_end(),de.get_start_and_end())
        self.add(circle,Polygon(a,b,c),Line(d,e),
            MathTex('A').next_to(a,UL),
            MathTex('B').next_to(b,DL),
            MathTex('C').next_to(c),
            MathTex('D').next_to(d,UP),
            MathTex('E').next_to(e,DOWN)
        )
        # p3
        self.add(
            MathTex('F').move_to([-0.3,1.2,0]),
            MathTex('G').move_to([-0.5,-2.1,0]),
            MathTex('H').move_to([-2.8,-0.5,0]),
            MathTex('J').move_to([0.7,-0.3,0])
        )
        self.wait()